package com.feng.common.validation.validator;

import com.feng.common.validation.constraints.OneOrZero;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author Feng
 * @since 2022/4/19 17:54
 */
public class OneOrZeroValidator implements ConstraintValidator<OneOrZero, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        return value == null || (value.equals(0) || value.equals(1));
    }
}
